<?php
namespace Callback\Controller;

use Think\Log;

class AliyunMtsController extends BaseController
{
    private $logFile;

    public function _initialize()
    {
        $this->logFile = $logFile = LOG_PATH . 'Callback/' . date('Y-m-d') . '_aliyunmts.log';
    }

    /**
     * 自动提取封面回调
     *
     * @return void
     */
    public function screenshot()
    {
        $xml = file_get_contents('php://input');
        $jsonObj = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);

        Log::write($jsonObj->Message, Log::INFO, '', $this->logFile);
        $message = json_decode($jsonObj->Message, true);
        if ($message['Name'] === 'activityEnd') {
            $mediaId = $message['MediaWorkflowExecution']['MediaId'];
            D('Helper/Media')->fill($mediaId);
        }
    }

}
